class_name SkillCard
extends Card

var effect_type: String
var effect_value: int
var upgraded_value: int

func _init(card_id: String, card_name: String, card_desc: String, card_cost: int, effect: String, value: int, card_rarity: int = 0, character_type: GameData.CharacterType = GameData.CharacterType.XU):
	super._init(card_id, card_name, card_desc, card_cost, GameData.CardType.SKILL, card_rarity, character_type)
	effect_type = effect
	effect_value = value
	upgraded_value = value + 1

func on_play() -> void:
	var game_data = GameData.get_instance()
	
	match effect_type:
		"block":
			# 获得护甲
			game_data.player_health += effect_value
		"energy":
			# 获得能量
			game_data.player_energy += effect_value
		"draw":
			# 抽牌
			for i in effect_value:
				game_data.draw_cards_to_hand()
		"heal":
			# 治疗
			game_data.player_health = min(game_data.player_health + effect_value, game_data.player_max_health)

func upgrade() -> void:
	effect_value = upgraded_value
	description = description.replace(str(effect_value - 1), str(effect_value))

func get_description() -> String:
	var desc = description
	match effect_type:
		"block":
			desc += " 获得 " + str(effect_value) + " 点护甲。"
		"energy":
			desc += " 获得 " + str(effect_value) + " 点能量。"
		"draw":
			desc += " 抽 " + str(effect_value) + " 张牌。"
		"heal":
			desc += " 恢复 " + str(effect_value) + " 点生命值。"
	return desc
